Векторные рисунки

Graphics[Circle[]]

Графические примитивы

Graphics[{
Circle[{0,0},1],
Disk[{1,1},1]
}]

Graphics[{
Rectangle[{-1,.25},{1,1}],
Polygon[{{-1,-.8},{-.5,0},{0,-.5},{.7,-.2},{1,-.8}}]
}]

pts={{-1,-.8},{-.5,0},{0,-.5},{.7,-.2},{1,-.8}};
Graphics[{Line[pts]}]
Graphics[{Point[pts]}]
Graphics[{Arrow[pts]}]

Graphics[{
Line[{{-1,1},{1,1}}],
InfiniteLine[{{-1,0},{1,1}}],
InfiniteLine[{-1,0},{1,1}],
HalfLine[{{-.5,1},{1,-1}}]
},PlotRange->#{{-1,1},{-1,1}}]&/@{1.5,3,10}

Circle[]
Disk[]
Rectangle[]
…
Polygon[]
Line[]
Point[]
…
InfiniteLine[]
HalfLine[]
Arrow[]
…

Параметры примитивов

Цвет заливки

Graphics[{
Disk[{0,0},1],
Gray,
Disk[{0,0},.7],
Disk[{1,1},1],
White,
Disk[{1,1},.5]
}]

Группы

Graphics[{
Disk[{0,0},1],
{Gray,
Disk[{0,0},.7]},
Disk[{1,1},1],
White,
Disk[{1,1},.5]
}]

Порядок

Graphics[{
Disk[{0,0},1],
Disk[{1,1},1],
Gray,
Disk[{0,0},.7],
White,
Disk[{1,1},.5]
}]

Параметры линий

Graphics[{
Line[pts],
Thick,
Line[#-{0,.2}&/@pts],
AbsoluteThickness[2],
Line[#-2{0,.2}&/@pts],
AbsoluteThickness[3],
Line[#-3{0,.2}&/@pts]
}]

Graphics[{
AbsoluteThickness[2] (* значение в пикселях *),
Line[pts],
Thickness[.01] (* значение в долях от ширины рисунка *),
Line[#-{0,.2}&/@pts]
},ImageSize->#]&/@{Tiny,Small,Medium}

Thick
Thin
Thickness[]
AbsoluteThickness[]

Graphics[{
Line[pts],
Dashed,
Line[#-{0,.2}&/@pts],
AbsoluteDashing[4],
Line[#-2{0,.2}&/@pts],
AbsoluteDashing[10],
Line[#-3{0,.2}&/@pts],
AbsoluteDashing[{10,40}],
Line[#-4{0,.2}&/@pts],
AbsoluteDashing[{10,20,4}],
Line[#-5{0,.2}&/@pts]
}]

Dashed
Dotted
DotDashed
Dashing[]
AbsoluteDashing[]
CapForm[]

Graphics[{
Point[pts[[1]]],
PointSize[.02],
Point[pts[[2]]],
AbsolutePointSize[5],
Point[pts[[3]]],
AbsolutePointSize[15],
Point[pts[[4]]],
AbsolutePointSize[Large],
Point[pts[[5]]]
}]

Обводка

Graphics[{
Disk[{0,0},1],
White,
Disk[{1,0},1],
White,EdgeForm[{Black}],
Disk[{2,0},1],
EdgeForm[Directive[Black,AbsoluteThickness[7]]],
Disk[{3,0},1],
Gray,
Disk[{4,0},1],
EdgeForm[Dashing[(1/8)(π/8)]],
Disk[{5,0},1]
},PlotRange->{{-1.5,6.5},1.2{-1,1}}]

Circle[] vs Disk[]

Graphics[{
Gray,
Disk[{0,0},1],
Directive[Black,AbsoluteThickness[7]],
Circle[{1,0},1]
},ImageSize->Small]

Graphics[{
Gray,
Disk[{0,0},1],
Directive[Black,AbsoluteThickness[7]]//EdgeForm,
White,Disk[{1,0},1]
},ImageSize->Small]

Graphics[{
Gray,
Disk[{0,0},1],
Directive[Black,AbsoluteThickness[7]]//EdgeForm,
Transparent,Disk[{1,0},1]
},ImageSize->Small]

Graphics[{
Gray,
Disk[{0,0},1],
White,
Disk[{1,0},1],
Directive[Black,AbsoluteThickness[7]],
Circle[{1,0},1]
},ImageSize->Small]

Повороты

Graphics[{
{White,EdgeForm[Directive[AbsoluteThickness[14],Black]],Rectangle[{-1,-1},{1,1}]},
Gray,
Rectangle[{-1,-1},{1,1}]
},PlotRange->1.5{{-1,1},{-1,1}}]

Graphics[{
White,{EdgeForm[Directive[AbsoluteThickness[14],Black]],Rectangle[{-1,-1},{1,1}]},Rectangle[{-1,-1},{1,1}],
Gray,
Rotate[Rectangle[{-1,-1},{1,1}],π/5]
},PlotRange->1.5{{-1,1},{-1,1}}]

Graphics[{
White,{EdgeForm[Directive[AbsoluteThickness[14],Black]],Rectangle[{-1,-1},{1,1}]},Rectangle[{-1,-1},{1,1}],
Gray,
Rotate[Rectangle[{-1,-1},{1,1}],π/5,{-1,1}]
},PlotRange->1.5{{-1,1},{-1,1}}]

Graphics[{
White,{EdgeForm[Directive[AbsoluteThickness[14],Black]],Rectangle[{-1,-1},{1,1}]},Rectangle[{-1,-1},{1,1}],
Gray,
Rotate[{
Rectangle[{-1,-1},{1,1}],
White,Rectangle[.25{-1,-1},.25{1,1}]
},π/5,{-1,1}]
},PlotRange->1.5{{-1,1},{-1,1}}]

Сопоставление с графиками

Plot[Sin[x],{x,0,10}]//FullForm

Plot[Sin[x],{x,0,10}]

Graphics[{
{,AbsoluteThickness[1.6],Line[{#,Sin[#]}&/@Range[0,10,.1]]}
},PlotRange->{{0,10},{-1,1}},PlotRangePadding->Scaled[.05],AspectRatio->1/GoldenRatio,Axes->True]

Замена графических выражений в графиках

Plot[Sin[x],{x,0,10}]/.Line->Arrow/.AbsoluteThickness[__]->Thickness[.008]

Встраивание графиков в рисунки

Graphics[{
InfiniteLine[{0,0},{0,1}],InfiniteLine[{0,0},{1,0}],
Plot[Sin[x],{x,0,10}][[1]]
},PlotRange->{{0,10},{-1,1}},PlotRangePadding->Scaled[.05],AspectRatio->1/GoldenRatio]

Встраивание рисунков в графики

Plot[Sin[x],{x,0,10},
Prolog->{Dashed,Gray,HalfLine[{0,1},{1,0}],InfiniteLine[{π/2,0},{0,1}]},
Epilog->{AbsolutePointSize[5],Point[{π/2,1}]}
]

Prolog — группа графических выражений,встраиваемая до основного графика
Epilog — группа графических выражений,встраиваемая после основного графика

Prolog vs Epilog

Plot[Sin[x],{x,0,10},
Prolog->{Yellow,AbsolutePointSize[15],Point[{π,0}]},
Epilog->{Pink,AbsolutePointSize[15],Point[{2π,0}]}
]
Plot[Sin[x],{x,0,10},
Epilog->{Yellow,AbsolutePointSize[15],Point[{π,0}]},
Prolog->{Pink,AbsolutePointSize[15],Point[{2π,0}]}
]

Graphics[{
{Yellow,AbsolutePointSize[15],Point[{π,0}]},
Plot[Sin[x],{x,0,10}][[1]],
{Pink,AbsolutePointSize[15],Point[{2π,0}]}
},AspectRatio->1/GoldenRatio,Axes->True]
Graphics[{
{Pink,AbsolutePointSize[15],Point[{2π,0}]},
Plot[Sin[x],{x,0,10}][[1]],
{Yellow,AbsolutePointSize[15],Point[{π,0}]}
},AspectRatio->1/GoldenRatio,Axes->True]

Цвета

Red//FullForm

RGBColor[1,0,0]

RGBColor[1,.5,0]
RGBColor[1,1,0]

RGBColor["#ff0088"]
RGBColor["#bada55"]

Выбор цветов

Purple
Darker[Purple]
Lighter[Purple]
Lighter[Purple,.75]

Blend[{Purple,Yellow},0]
Blend[{Purple,Yellow},.5]
Blend[{Purple,Yellow},1]

Graphics[{Thickness[.025],
{Blend[{,},1-#],
Circle[{-.9#,0},#]}&/@Range[1,0,-.1]
}]

Black//FullForm

GrayLevel[0]
GrayLevel[0.5]
GrayLevel[1]

Прозрачность

Graphics[{
,Disk[],
,Opacity[.5],Disk[{1,0}]
},ImageSize->Small]

Graphics[{
,Disk[],
Opacity[.5,],Disk[{1,0}]
},ImageSize->Small]

Параметрическая анимация

Pic[φ_]:=Graphics[{
Circle[],Disk[{Cos[φ],Sin[φ]}-.4{Cos[4φ],-Sin[4φ]},.2]
},PlotRange->1.75{{-1,1},{-1,1}}];

Animate[Pic[2π t],{t,0,1}]

Manipulate[]
Animate[]
ListAnimate[]

Dynamic[]
Manipulator[]
Animator[]